package com.hymjweb.demo.hymj.native_bill_manage.sign_choose_detail.service;

import com.hymjweb.demo.framework.sys.BaseService;
import com.hymjweb.demo.framework.util.DataTypeUtil;
import com.hymjweb.demo.hymj.native_bill_manage.sign_choose_detail.bean.BNativeBillSignChooseDetailPojo;
import com.hymjweb.demo.hymj.native_bill_manage.sign_choose_detail.mapper.BNativeBillSignChooseDetailMapper;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;
import org.springframework.transaction.annotation.Transactional;

import java.util.Date;
import java.util.List;

@Service
public class BNativeBillSignChooseDetailService extends BaseService {

    @Autowired
    private BNativeBillSignChooseDetailMapper bNativeBillSignChooseDetailMapper;

    public List<BNativeBillSignChooseDetailPojo> queryBillSignStatusByBillId(String billId) {
        return bNativeBillSignChooseDetailMapper.queryBillSignStatusByBillId(billId);
    }

    @Transactional(rollbackFor = {Exception.class})
    public int addBillSignStatus(BNativeBillSignChooseDetailPojo pojo) throws Exception {
        if(pojo==null){
            throwException("添加分单签收状态参数错误!");
        }
        pojo.setId(this.getSysStrId());
        Date currentTime = this.getSysTime();
        String czyId = this.getLoginCzyId();

        pojo.setCreateTime(currentTime);
        pojo.setCreateUserId(czyId);
        pojo.setUpdateTime(currentTime);
        pojo.setUpdateUserId(czyId);

        return bNativeBillSignChooseDetailMapper.insert(pojo);
    }

    @Transactional(rollbackFor = {Exception.class})
    public int deleteBillSignStatusById(String id) throws Exception {
        if(DataTypeUtil.isEmptyStr(id)){
            throwException("删除分单签收状态参数错误!");
        }
        return bNativeBillSignChooseDetailMapper.delete(id);
    }
}
